<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <title>报备资料查询</title>
    <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function TabReplace() {
            if (event.keyCode == 13) {
                if (event.srcElement.tagName != 'BUTTON')
                    event.keyCode = 9;
                else
                    event.srcElement.click();
            }
        }
    </script>
</ui:define>
<ui:define name="content">
    <h:form id="form" enctype="multipart/form-data">
        <!--<p:focus for="id"/>-->
        <p:growl id="msgs" showDetail="true"/>
        <p:ajaxStatus style="width:16px;height:16px;">
            <f:facet name="start">
                <h:graphicImage value="/images/ajaxloading.gif"/>
            </f:facet>
            <f:facet name="complete">
                <h:outputText value=""/>
            </f:facet>
        </p:ajaxStatus>
        <p:dataTable id="tabSum" style="width:100%;"
                     value="#{enterResouceBackupAction.thebrsList}"
                     var="thebrs"
                     rowKey="#{thebrs.pkid}"
                     selectionMode="single"
                     selection="#{enterResouceBackupAction.thebrsSelected}"
                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
              {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                     paginator="true"
                     paginatorPosition="bottom"
                     rows="15"
                     rowsPerPageTemplate="100,50,30,15,5"
                     emptyMessage="数据记录为空..." rowIndexVar="index">
            <p:ajax event="rowSelect" listener="#{enterResouceBackupAction.getAllThebrds()}" update=":form:tabDetail"/>

            <p:column style="text-align:center">
                <f:facet name="header">
                    <h:outputText value="序号"/>
                </f:facet>
                <h:outputText value="#{index + 1}"/>
            </p:column>

            <p:column style="text-align:center" filterBy="#{thebrs.taxpayer_id}" filterMatchMode="contains">
                <f:facet name="header">
                    <h:outputText value="纳税人识别号" />
                </f:facet>
                <h:outputText value="#{thebrs.taxpayer_id}"/>
            </p:column>

            <p:column style="text-align:center" filterBy="#{thebrs.taxpayer_name}" filterMatchMode="contains">
                <f:facet name="header">
                    <h:outputText value="纳税人名称"/>
                </f:facet>
                <h:outputText value="#{thebrs.taxpayer_name}"/>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrs.project_id}">
                <f:facet name="header">
                    <h:outputText value="项目编号"/>
                </f:facet>
                <h:outputText value="#{thebrs.project_id}"/>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrs.project_name}">
                <f:facet name="header">
                    <h:outputText value="开发项目"/>
                </f:facet>
                <h:outputText value="#{thebrs.project_name}"/>
            </p:column>

            <p:column style="text-align:center;" sortBy="#{thebrs.resource_num}">
                <f:facet name="header">
                    <h:outputText value="备案资料(份数)"/>
                </f:facet>
                <h:outputText value="#{thebrs.resource_num}"/>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrs.accepter}">
                <f:facet name="header">
                    <h:outputText value="受理人"/>
                </f:facet>
                <h:outputText value="#{thebrs.accepter}"/>
                <f:facet name="footer">
                    <h:outputText value="笔数：#{fn:length(enterResouceBackupAction.thebrsList)}"/>
                </f:facet>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrs.accept_date}">
                <f:facet name="header">
                    <h:outputText value="受理日期"/>
                </f:facet>
                <h:outputText value="#{thebrs.accept_date}">
                    <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" locale="cn"></f:convertDateTime>
                </h:outputText>
                <f:facet name="footer">
                    <h:commandLink>
                        <h:outputText value="[导出数据]"/>
                        <p:dataExporter type="xls" target="tabSum" fileName="qybbzltjb"/>
                    </h:commandLink>
                </f:facet>
            </p:column>

        </p:dataTable>
        <p:separator/>
        <p:dataTable id="tabDetail" style="width:100%;"
                     value="#{enterResouceBackupAction.thebrdList}"
                     var="thebrd"
                     rowKey="#{thebrd.pkid}"
                     selectionMode="single"
                     selection="#{enterResouceBackupAction.thebrdSelected}"
                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
              {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                     paginator="true"
                     paginatorPosition="bottom"
                     rows="15"
                     rowsPerPageTemplate="100,50,30,15,5"
                     emptyMessage="数据记录为空..." rowIndexVar="index">

            <f:facet name="header">
                <h:outputText value="附件列表"/>
            </f:facet>
            <p:column style="text-align:center">
                <f:facet name="header">
                    <h:outputText value="序号"/>
                </f:facet>
                <h:outputText value="#{index + 1}"/>
            </p:column>

            <p:column style="text-align:center;" sortBy="#{thebrd.resource_code}">
                <f:facet name="header">
                    <h:outputText value="资料代码"/>
                </f:facet>
                <h:outputText value="#{thebrd.resource_code}"/>
            </p:column>

            <p:column style="text-align:center" filterBy="#{thebrd.resource_name}" filterMatchMode="contains">
                <f:facet name="header">
                    <h:outputText value="备案资料"/>
                </f:facet>
                <h:outputText value="#{thebrd.resource_name}"/>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrd.idNo}">
                <f:facet name="header">
                    <h:outputText value="证件号码"/>
                </f:facet>
                <h:outputText value="#{thebrd.idNo}"/>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrd.inputer}">
                <f:facet name="header">
                    <h:outputText value="录入人"/>
                </f:facet>
                <h:outputText value="#{thebrd.inputer}"/>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrd.input_date}">
                <f:facet name="header">
                    <h:outputText value="录入日期"/>
                </f:facet>
                <h:outputText value="#{thebrd.input_date}">
                    <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" locale="cn"></f:convertDateTime>
                </h:outputText>
            </p:column>

            <p:column style="text-align:center" sortBy="#{thebrd.file_name}">
                <f:facet name="header">
                    <h:outputText value="位图文件名称"/>
                </f:facet>
                <h:outputText value="#{thebrd.file_name}"/>
            </p:column>
            <p:column style="text-align:center">
                <f:facet name="header">
                    <h:outputText value="预览"/>
                </f:facet>
                <p:commandLink actionListener="#{enterResouceBackupAction.preview(thebrd.file_name)}" update=":form:preimage"
                               oncomplete="preview.show()">
                    <h:outputText value="预览"/>
                </p:commandLink>
                <f:facet name="footer">
                    <h:outputText value="笔数：#{fn:length(enterResouceBackupAction.thebrdList)}"/>
                </f:facet>
            </p:column>

            <p:column style="text-align:center">
                <f:facet name="header">
                    <h:outputText value="下载"/>
                </f:facet>
                <p:commandLink id="download" actionListener="#{enterResouceBackupAction.download()}" ajax="false">
                    <f:param name="taxpayer_id" value="#{thebrd.taxpayer_id}"/>
                    <f:param name="project_id" value="#{thebrd.project_id}"/>
                    <f:param name="file_name" value="#{thebrd.file_name}"/>
                    <f:param name="resource_name" value="#{thebrd.resource_name}"/>
                    <p:graphicImage alt="下载" value="/images/download.png" style="border: 0"/>
                    <p:fileDownload value="#{enterResouceBackupAction.downloadFile}"/>
                </p:commandLink>
                <f:facet name="footer">
                    <h:commandLink>
                        <h:outputText value="[导出数据]"/>
                        <p:dataExporter type="xls" target="tabDetail" fileName="qybbzlmxb"/>
                    </h:commandLink>
                </f:facet>
            </p:column>
        </p:dataTable>

        <p:dialog id="preview" widgetVar="preview" header="预览文件" showEffect="drop"
                  hideEffect="drop" style="text-align: center;" modal="true">
            <p:graphicImage id="preimage" value="#{enterResouceBackupAction.selectFileName}"/>
        </p:dialog>
    </h:form>
</ui:define>
</ui:composition>